import { createChannel, createClientFactory, FetchTransport, CallOptions, ClientMiddleware } from "nice-grpc-web";
import { ActivityServiceDefinition } from "@/types/proto/api/v1/activity_service";
import { AuthServiceDefinition } from "@/types/proto/api/v1/auth_service";
import { IdentityProviderServiceDefinition } from "@/types/proto/api/v1/idp_service";
import { InboxServiceDefinition } from "@/types/proto/api/v1/inbox_service";
import { MarkdownServiceDefinition } from "@/types/proto/api/v1/markdown_service";
import { WebhookServiceDefinition } from "@/types/proto/api/v1/webhook_service";
import { SystemServiceDefinition } from "@/types/proto/api/v1/system_service";
import { SystemSettingServiceDefinition } from "@/types/proto/api/v1/system_setting_service";

const channel = createChannel(
  window.location.origin,
  // 'http://127.0.0.1:7227',
  FetchTransport({
    credentials: "include",
  }),
);



const clientFactory = createClientFactory();

export const systemServiceClient = clientFactory.create(SystemServiceDefinition, channel);

export const systemSettingServiceClient = clientFactory.create(SystemSettingServiceDefinition, channel);

export const authServiceClient = clientFactory.create(AuthServiceDefinition, channel);

export const inboxServiceClient = clientFactory.create(InboxServiceDefinition, channel);

export const activityServiceClient = clientFactory.create(ActivityServiceDefinition, channel);

export const webhookServiceClient = clientFactory.create(WebhookServiceDefinition, channel);

export const markdownServiceClient = clientFactory.create(MarkdownServiceDefinition, channel);

export const identityProviderServiceClient = clientFactory.create(IdentityProviderServiceDefinition, channel);

